package com.vito.oa.act.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.vito.base.model.DataGrid;
import com.vito.oa.act.dao.ActUserProcessSettingMapper;
import com.vito.oa.act.extend.model.OaActExBussDefModel;
import com.vito.oa.act.model.ActUserNodeSettingModel;
import com.vito.oa.act.model.ActUserProcessSettingModel;
import com.vito.oa.act.service.ActUserProcessSettingService;

@Service
public class ActUserProcessSettingServiceImpl implements ActUserProcessSettingService {
	@Autowired
	private ActUserProcessSettingMapper actUserProcessSettingMapper;
	@Override
	public int updateUserProcessSetting(ActUserProcessSettingModel setting) {
		return actUserProcessSettingMapper.updateUserProcessSetting(setting);
	}

	@Override
	public ActUserProcessSettingModel queryUserProcessSetting(String processKey, String companyId) {
		return actUserProcessSettingMapper.queryUserProcessSetting(processKey, companyId);
	}

	@Override
	public int updateNodesSetting(ActUserNodeSettingModel nodeSetting) {
		return actUserProcessSettingMapper.updateNodesSetting(nodeSetting);
	}

	@Override
	public List<ActUserNodeSettingModel> queryUserNodesSetting(String processKey, String companyId) {
		return actUserProcessSettingMapper.queryNodesSetting(processKey, companyId);
	}
	
	@Override
	public DataGrid<ActUserNodeSettingModel> queryUserNodesSettingByPage(ActUserProcessSettingModel setting) {
		DataGrid<ActUserNodeSettingModel> gird = new DataGrid<ActUserNodeSettingModel>();
		gird.setRows(actUserProcessSettingMapper.queryNodesSettingByPage(setting));
		gird.setTotal(setting.getTotal());
		return gird;
	}
	
	@Override
	public ActUserProcessSettingModel queryProcessAndNodeSetting(String processKey, String companyId) {
		ActUserProcessSettingModel setting =  actUserProcessSettingMapper.queryUserProcessSetting(processKey, companyId);
		List<ActUserNodeSettingModel> nodes = actUserProcessSettingMapper.queryNodesSetting(processKey, companyId);
		setting.setNodeSetting(nodes);
		return setting;
	}

}
